#pragma once
#include "CompletePort.h"
#include "Core.h"
#include "ICompletePort.h"

class NetTask:public CObject,public ICompletePort
{
public:
	void Start();

	void Stop();

	void Pool(uint32 ms=INFINITE);
	
private:
	class NetTaskUnit:public CTask
	{
	public:
		NetTaskUnit(NetTask*);

	private:
		virtual void Run();
		virtual void OnStart();
		virtual void OnStop();

		NetTask* m_pTask;
	};

	virtual void Active(HANDLE h,void* obj);
private:
	volatile long					m_nWorkThreadCount;
	volatile long					m_nStopThreadCount;
	std::vector<NetTaskUnit*>		m_vTasks;
	CompletePort*					m_pCompletePort;	
};